package huawei;
/*
* @Author: wanghongfucoder
* @Date:   2017-06-28 16:59:56
* @Last Modified by:   wanghongfucoder
* @Last Modified time: 2017-06-28 17:14:02
*/

import java.util.*;

public class Calculator {
  
public static int getValue(String str) {
char[] arr=str.toCharArray();
trans(arr);
return value(arr, 0)[0];
}
public static void trans(char[] arr){
for(int i=0;i<arr.length;i++){
if(arr[i]=='['||arr[i]=='{')
arr[i]='(';
if(arr[i]==']'||arr[i]=='}')
arr[i]=')';
}
}
public static int[] value(char[] str, int i) {
LinkedList<String> que = new LinkedList<String>();
int pre = 0;
int[] bra = null;
while (i < str.length && str[i] != ')') {
if (str[i] >= '0' && str[i] <= '9') {
pre = pre * 10 + str[i++] - '0';
} else if (str[i] != '(') {
addNum(que, pre);
que.addLast(String.valueOf(str[i++]));
pre = 0;
} else {
bra = value(str, i + 1);
pre = bra[0];
i = bra[1] + 1;
}
}
addNum(que, pre);
return new int[] { getNum(que), i };
}
  
public static void addNum(LinkedList<String> que, int num) {
if (!que.isEmpty()) {
int cur = 0;
String top = que.pollLast();
if (top.equals("+") || top.equals("-")) {
que.addLast(top);
} else {
cur = Integer.valueOf(que.pollLast());
num = top.equals("*") ? (cur * num) : (cur / num);
}
}
que.addLast(String.valueOf(num));
}
  
public static int getNum(LinkedList<String> que) {
int res = 0;
boolean add = true;
String cur = null;
int num = 0;
while (!que.isEmpty()) {
cur = que.pollFirst();
if (cur.equals("+")) {
add = true;
} else if (cur.equals("-")) {
add = false;
} else {
num = Integer.valueOf(cur);
res += add ? num : (-num);
}
}
return res;
}
  
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
         while(sc.hasNext()){
             String str=sc.next();
             System.out.println(getValue(str));
         }
}
}
/*
 *
 * import java.util.ArrayList;
import java.util.Scanner;
import java.util.Stack;
 
public class Main{
     
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
         
        while(sc.hasNext()){
            Stack stack=new Stack();
            String str=sc.nextLine();
 
             
            ArrayList<String>input=new ArrayList<String>();
            StringBuilder sb=new StringBuilder();
             
            for(int i=0;i<str.length();i++){
                char c=str.charAt(i);
                if(Character.isDigit(c))
                    sb.append(c);
                else{
                    if(sb.length()!=0){
                         input.add(sb.toString());
                         input.add(str.charAt(i)+"");
                         sb.delete(0, sb.length());
                    }
                    else
                         input.add(str.charAt(i)+"");
                }
            }
            if(sb.length()!=0)
                 input.add(sb+"");
            //System.out.println(input);
             
            ArrayList<String>output=new ArrayList<String>();
            output=InToPost(stack, input);
            //System.out.println(output);
             
            int result=Compute(output);
            System.out.println(result);
        }
    }
     
    public static ArrayList InToPost(Stack<String> stack,ArrayList input){
         
        ArrayList<String> post=new ArrayList<String>();
        int prec1;
        for(int i=0;i<input.size();i++){
             
            String c= (String) input.get(i);
             
            if(c.equals("+")||c.equals("-")){
                prec1=1;
                while(!stack.isEmpty()){
                     String opTop=stack.peek();
                     if(opTop.equals("(")){
                            break;
                      }
                     else{
                            int prec2;
                            if(opTop.equals("+")||opTop.equals("-"))
                                prec2=1;
                            else
                                prec2=2;
                         
                                post.add(stack.pop());
                     }
                }
                  stack.push(c);
            }    
            else if(c.equals("*")||c.equals("/")){
                 prec1=2;
                while(!stack.isEmpty()){
                    String  opTop=stack.peek();
                      if(opTop.equals("(")){
                            break;
                      }
                     else{
                            int prec2;
                            if(opTop.equals("+")||opTop.equals("-"))
                                prec2=1;
                           else
                                prec2=2;
                        if(prec2<prec1){
                            break;
                        }
                        else
                            post.add(stack.pop());
                    }
                }
                     stack.push(c);
            }
            else if(c.equals("("))
                stack.push(c);
             
            else if(c.equals(")")){
                while(!stack.isEmpty()){
                    String ch= stack.pop();
                    if(ch.equals("("))  break;
                    else
                        post.add(ch);;
                }
            }
             
            else
                post.add(c);
             
            }
         
        while(!stack.isEmpty()){
            post.add(stack.pop());
        }
        return post;
    }
 
  public static int Compute( ArrayList<String>post){
     
        Stack<Integer> stack=new Stack<Integer>();
        String c;
        for(int i=0;i<post.size();i++){
            c=post.get(i);
            if(c.equals("+")||c.equals("-")||c.equals("*")||c.equals("/")){
                int num2= stack.pop();
                int num1= stack.pop();
                if(c.equals("+"))              stack.push(num1+num2);
                else if(c.equals("-"))      stack.push(num1-num2);
                else if(c.equals("*"))     stack.push(num1*num2);
                else    stack.push(num1/num2);
                 
            }
            else     
                stack.push(Integer.parseInt(c));
        }
        return stack.pop();
     
    }
 
}
 */
